<?php

namespace app\admin\controller;

use app\admin\service\AuthService;
use app\Request;
use app\admin\service\LoginService;
use app\BaseController;

class Login extends BaseController
{
    /**
     * 登录
     * @author dgc<453342213@qq.com>
     * createTime:2020/8/24 11:53
     */
    public function index()
    {
        try {
            $service = new LoginService();
            $data = $this->checkParam(['username', 'password']);
            $token = $service->Login($data);
            returnDate($token);
        } catch (\Exception $e) {
            returnMsg($e->getMessage(), $e->getCode());
        }
    }

    public function out(Request $request)
    {
        //删除之前的缓存
        redisHdel('admin_user_info', 'admin_' . $request->header('token'));
        returnDate();
    }
}
